<?php
session_start();
include "config/identitas-situs.php";
include "config/class_paging.php";

?>
<?php
require 'menu_atas.php';
$user_id=$_SESSION['user_id'];
?>

<html><head>
<title>Lihat Pendaftar <?php echo $title; ?></title>
<link rel="shortcut icon" href="images/fav.ico" />
<link href="config/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
 
<?php
include "config/koneksi.php";
?>
	 
  <div id="isi">
<?php
$hal=$_GET[halaman];
//HALAMAN DAFTAR CALON SISWA
if($hal=="full-siswa"){
?>
 <style type="text/css">
   </style>
	<H1 align="center">Data Pendaftar  
	&nbsp <a href="welcome_login.php"><font size="1">Kembali ke menu setelah login</font></a>&nbsp &nbsp</H1>
	<fieldset style="border:3px solid #bde599" width="400px">
	<legend style="font-weight:bold; color:#0066CC">
	 
	 <a href="index1.php?halaman=urut-siswa" style="text-decoration:none">
	   <button><blink> ******* </blink>Silahkan klik untuk melihat pendaftar berdasarkan Program Keahlian<blink> ******* </blink></button>
	 </a>
	 
	</legend>
	<div style="overflow:scroll; width:900px">
	 <table align="center" id="belang" width="900px">
		<tr>
			<th width="4%">No.</th>
			<th width="5%">No.Daftar</th>
			<th width="20%">Proli</th>
			<th width="40%">Nama</th>
			<th width="50%">Asal Sekolah</th>
			<th width="5%">Matematika</th>
			<th width="5%">Bhs.Indonesia</th>
			<th width="5%">Bhs.Inggris</th>
			<th width="5%">Ipa</th>
			<th width="5%">Jumlah</th>
			<th width="5%">Rata-rata</th>
		</tr>
	<?php	
	$p       = new Paging;
	$batas   = 5;
	$posisi  = $p->cariPosisi($batas);
	
	$q2=mysql_query("SELECT * FROM tb_pendaftar ORDER BY no_pendaftaran ASC LIMIT $posisi,$batas");
	$no=$posisi+1;
	while($r2=mysql_fetch_array($q2)){
	
	$tgl_posting=tanggalan($r2[tanggal]);
	
	$agama=mysql_fetch_array(mysql_query("SELECT * FROM tb_agama WHERE id_agama= '$r2[id_agama]'"));
	if($r2[jk]=="1"){
	$jk ="Laki-Laki";
	}else{
	$jk="Perempuan";}
	?>
	    <tr>
	    	<td align="center">
	    		<?php echo $no; ?>
	    	</td>
			<td align-"center">
				<?php echo $r2[no_pendaftaran]; ?>
			</td>
			 <? $proli=mysql_query("SELECT * FROM tb_proli WHERE kd_proli = '$r2[proli]'");
	$k=mysql_fetch_array($proli);?>
            <td align="center">
				<?php echo $k[proli]; ?>
			</td>
			<td>
				<?php echo $r2[nama]; ?>
			</td>
			<td>
				<?php echo $r2[asal_sekolah]; ?>
			</td>
			<td align="center">
            <? $nilai=mysql_query("SELECT * FROM tb_pendaftar WHERE no_pendaftaran = '$r2[no_pendaftaran]'");
		$n=mysql_fetch_array($nilai);?>
         
                <?php echo $n[matematika]; ?>
            </td>
            <td align="center">
                <?php echo $n[indonesia]; ?>
            </td>
            <td align="center">
                <?php echo $n[inggris]; ?>
            </td>
			<td align="center">
                <?php echo $n[ipa]; ?>
            </td>
             <td align="center">
                <?php 
				$jumlah=mysql_query("select matematika,indonesia,inggris, ipa ,((4*matematika)+(1*indonesia)+(3*inggris)+(2*ipa)) AS jumlah FROM tb_pendaftar WHERE no_pendaftaran = '$r2[no_pendaftaran]'");
		$j=mysql_fetch_array($jumlah); 
				echo $j[jumlah]; ?>
            </td>
			<td align="center">
                <?php 
				$rata2=mysql_query("select matematika,indonesia,inggris, ipa ,(((4*matematika)+(1*indonesia)+(3*inggris)+(2*ipa)) div 10) AS rata2 FROM tb_pendaftar WHERE no_pendaftaran = '$r2[no_pendaftaran]'");
		$r=mysql_fetch_array($rata2); 
				echo $r[rata2]; ?>
            </td>
            
              <?php
			   if ($n['status_aktif']=='aktif'){
				$img_status="lamp-green.gif";
				$link_status="update_status.php?status=nonaktif&id=".$n['id_pendaftaran'];
			   $status="terima";}
			   else {
				$img_status="lamp-off.gif";
				$link_status="update_status.php?status=aktif&id=".$n['id_pendaftaran'];
				$status="tidak terima";}
				?>
          
		
		
		</tr>
	<?php
	$no++;
	}
	?>
	</table>
	</div>
	<?php
	$jmldata=mysql_num_rows(mysql_query("SELECT * FROM tb_pendaftar"));
	$jmlhalaman = $p->jumlahHalaman($jmldata,$batas);
	$linkHalaman = $p->navHalaman($_GET[hal], $jmlhalaman);
	echo "<div class=pagination align=center>$linkHalaman</div><br>";
	
	?>
	<br/>
  
	<?php
}


//HALAMAN TAMBAH SISWA
elseif($hal=="tambah-siswa"){
?>

<?php
}
//HALAMAN DAFTAR NILAI
elseif($hal=="nilai-siswa"){
?>
 
	
<?php
}

//HALAMAN EDIT SISWA
elseif($hal=="edit-siswa"){
	$edit=mysql_query("SELECT * FROM tb_pendaf WHERE no_pendaftaran = '$_GET[id]'");
	$e=mysql_fetch_array($edit);
?>



<?php	
}

//HALAMAN URUTAN Pendaftar BERDASARKAN---
elseif($hal=="urut-siswa"){
?>
 <style type="text/css">
   
   </style>
 <form action="index1.php?halaman=urut-siswa" method="post">
 <b>Tampilkan Berdasarkan : </b> 
  * Proli &nbsp;<select name="proli">
  <?php
  $proli=mysql_query("SELECT * FROM tb_proli");
  while($upro=mysql_fetch_array($proli)){
   echo "<option value='$upro[kd_proli]'>$upro[proli]</option>";
  }
  ?>
 </select>
  <input type="submit" name="urutkan" value="Tampilkan" />
 &nbsp &nbsp
  <a href="index1.php?halaman=full-siswa"><font size="1">Kembali ke Data Pendaftar</font></a> &nbsp &nbsp
  <a href="welcome_login.php"><font size="1">Kembali ke menu setelah login</font></a>
  
</form>
	
	<br />
	<?php
if(isset($_POST['urutkan'])){
?>
	<fieldset style="border:3px solid #bde599" width="500px">
	<legend style="font-weight:bold; color:#0066CC">
	Nama Pendaftar : 
	</legend><div style="overflow:scroll; width:900px">
    <?
    $tgl_posting=tanggalan($r3[tanggal]);
	$proli=$_POST['proli'];
	$vkelas=mysql_fetch_array(mysql_query("select * from tb_proli where kd_proli='$_POST[proli]'"));
	$kuota=$vkelas['kuota'];
	//echo 'kuota '.$kuota;
	$sql_urut="SELECT * FROM (
			SELECT no_pendaftaran,id_pendaftaran,nama,matematika,indonesia,inggris, ipa ,asal_sekolah,
			((4*matematika)+(1*indonesia)+(3*inggris)+(2*ipa)) AS jumlah
			FROM tb_pendaftar
			WHERE proli='".$proli."') AS data_raw 
			ORDER BY jumlah DESC,matematika  DESC ";
			//echo $sql_urut;
			$q3=mysql_query($sql_urut);
				
?>

	<table id="belang" align="center" width="100%">
		<tr>
			<th width="4%">No</th>
			<th width="5%">No Pendaftaran</th>
			<th width="20%">Nama</th>
			<th width="20%">Asal Sekolah</th>
			<th width="5%"> Matematika</th>
			<th width="5%"> Bhs.Indonesia</th>
			<th width="5%"> Bhs.Inggris</th>
			<th width="5%"> IPA</th>
			<th width="5%">Jumlah</th>
			<th width="10%" align="center">Rata-rata</th>
		
		</tr>
	<?php	
	/* menampilkan semua siswa  */

	$no=1;
	while($r3=mysql_fetch_array($q3)){
		  $proli=mysql_query("SELECT * FROM tb_proli WHERE kd_proli = '$r3[proli]'");
	$k=mysql_fetch_array($proli);
				
				if($r3[jk]=="1")
				{
					$jk ="Laki-Laki";
				}
				else
				{
					$jk="Perempuan";
				}
				/*
				if ($r3[status]=='1')
			   
			   {
			   $status="terima";}
			   else {
				$status="tidak terima";}
				*/
				/*if($no <=$kuota){
					$status='Diterima';
				}else{
					$status='Tidak Diterima';
				}
	*/
				$rata=round($r3['jumlah']/10,2);
	
				?>
			
				
<tr>
					<td align="center"><?php echo $no; ?></td>
					<td align="center"><?php echo $r3['no_pendaftaran']; ?></td>
					<td><?php echo $r3[nama]; ?></td>
	                <td><?php echo $r3['asal_sekolah']; ?></td>
            		<td align="center"><?php echo $r3[matematika]; ?></td>
					<td align="center"><?php echo $r3[indonesia]; ?></td>
                    <td align="center"><?php echo $r3[inggris]; ?></td>
					<td align="center"><?php echo $r3[ipa]; ?></td>
         <td align="center">
         <?php echo $r3['jumlah']; ?>
         </td>
                   
             
              <?php
			   
				?>
				 <td align="center">
				   <?php echo $rata; ?> 
				   	
                
                   </td>
                   		   
				   
				   </tr>
                   <?
					$no++;
	}	
	$k=$_POST[jurusan];
	?>
			
		</table>
		</div>
		
        <br/>
  
		</fieldset>
		<?php
		}
		?>
		
		
<?php
}

?>
	 

</div>
 	<div style="clear:both" />
 	<div id="footer" align="center"><?php echo $namasitus; ?> <br><br>&copy; 2014. Copyrigt by: <a href="author.php">Lulu Infajaroh</a>
	<a href="#header" title="Kembali ke Atas"><img src="images/go-top.png" style="float:right; width:15px; height:15px;" /></a></div>
 </div>
	</body>
    </html>
